/*
 Copyright 2011 Dario Seitel, Sebastian Mayer. All rights reserved.

 Redistribution and use in source and binary forms, with or without modification, are
 permitted provided that the following conditions are met:

 1. Redistributions of source code must retain the above copyright notice, this list of
 conditions and the following disclaimer.

 2. Redistributions in binary form must reproduce the above copyright notice, this list
 of conditions and the following disclaimer in the documentation and/or other materials
 provided with the distribution.

 THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY EXPRESS OR IMPLIED
 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 The views and conclusions contained in the software and documentation are those of the
 authors and should not be interpreted as representing official policies, either expressed
 or implied, of <copyright holder>.
 */

#ifndef PLAYER_H_
#define PLAYER_H_

#include <iostream>
#include <list>
#include <SFML/Window.hpp>
#include "Entity.h"
#include "Moveable.h"
#include "Rotateable.h"

using std::string;

class Collectible;
class Flag;

/**
 * The player entity
 */
class Player: public Entity, public Moveable, public Rotateable {
public:
	enum MOVEDIRECTION {NONE, UP, DOWN, RIGHT, LEFT};

	struct MOVE {
		float positionX;
		float positionY;
		int delay;
		int timestamp_sender;
		int timestamp_receiver;
	};

	struct MOVE_TRANSLATION {
		MOVE move;
		MOVEDIRECTION translation;
	};

	struct MOVE_ROTATION {
		MOVE move;
		MOVEDIRECTION rotation;
	};

	Player();
	virtual ~Player();

	virtual void render();
	virtual void init();
	/**
	 * @return true if this player is currently able to shoot, false otherwise
	 */
	virtual bool canShoot();
	/**
	 * @param shotDelay the required cooldown delay between two shots in seconds
	 */
	virtual void setShotDelay(float shotDelay);

	/**
	 * Called if the player collects something
	 * @param collectible the collected item
	 */
	virtual void onCollect(Collectible* collectible);
	virtual void onCollect(Flag* collectible);

	virtual MOVE_ROTATION getMoveRotation();
	virtual MOVE_TRANSLATION getMoveTranslation();
	virtual string getName();

	virtual void setMoveRotation(MOVE_ROTATION moveRotation);
	virtual void setMoveTranslation(MOVE_TRANSLATION moveTranslation);
	virtual void setName(string name);

private:
	string name;
	float shotDelay;
	sf::Clock shotTimer;
	GLuint displayListIndex;
	MOVE_ROTATION moveRotation;
	MOVE_TRANSLATION moveTranslation;
};

#endif /* PLAYER_H_ */
